<?php
namespace jy_xiyi;
defined('BY_JYA') or exit('error');
/*
	代收点	
*/
class daishou extends \plugin{
	/*
		指派订单
	*/
	public function create_order($order){
		if(!$this->plugin_exists('jy_area_dian')){
			return false;
		}
		if(!$this->setting['isopendai']){
			return false;	
		}
		
		$address['pcd']=json_decode($address['pcd'],true);
		if($this->setting['daitype']!=2){
			$dians=model('jy_area_dian/model')->get_dians($order);
			$dian_id=$dians[0]['id'];
		}
		$data=array(
				'uniacid'=>$_SESSION['uniacid'],
				'mid'=>$order['mid'],
				'orderid'=>$order['id'],
				'order_price'=>$order['price'],
				'sendtype'=>$order['sendtype'],
				'daitype'=>$this->setting['daitype'],
				'dian_id'=>$dian_id,
				'createtime'=>TIMESTAMP,
				'status'=>$dian_id?1:0,
		);
		pdo_insert('jy_area_dian_order',$data);
	}
	/*
		指派收货点
	*/
	public function to_daishou($orderid=0,$dian_id=0){
		if(!$orderid || $dian_id){
			exi('请选择订单和收货点','error');
		}
		pdo_update('jy_area_dian_order',array('dian_id'=>$dian_id,'status'=>1,'uptime'=>TIMESTAMP),array('orderid'=>$orderid));
		return true;
	}
}